<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY copy "&#169;">
  <!ENTITY nbsp "&#160;">
  <!ENTITY laquo "&#171;">
  <!ENTITY raquo "&#187;">
]>
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <xsl:output encoding="UTF-8"
              method="xml"
              omit-xml-declaration="yes"
              indent="no"
              doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
              doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

  <xsl:variable name="Root" select="/page/settings/url" />
  <xsl:variable name="Files" select="/page/settings/files_url" />
  <xsl:variable name="Images" select="/page/settings/images_url" />
  <xsl:variable name="Settings" select="/page/settings" />
  <xsl:variable name="Controller" select="/page/settings/controller" />
  <xsl:variable name="Action" select="/page/settings/action" />
  <xsl:variable name="This" select="/page/settings/this" />
  <xsl:variable name="Main" select="/page/content/Main" />
  <xsl:variable name="User" select="/page/content/auth-info" />
  <xsl:variable name="Content" select="/page/content" />
  <xsl:variable name="Cats" select="/page/content/Cats" />
  <xsl:variable name="Cat" select="/page/content/@cat" />
  <xsl:variable name="Form" select="/page/content/Main/form" />
  <xsl:variable name="Date" select="/page/content/current-date" />
  <xsl:variable name="Messages" select="/page/content/messages" />

  <xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="page">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>
          <xsl:value-of select="$Settings/title"/>
          <xsl:text> </xsl:text>
          <xsl:value-of select="$Settings/version"/>
        </title>

        <link href="/images/favicon.ico" rel="shortcut icon"/>
        <xsl:choose>
            <xsl:when test="$Settings/is_mobile != ''">
                <link href="/css/mobile_main.css" rel="stylesheet" type="text/css" />
                <link rel="stylesheet" href="/js/popup/popup.css" type="text/css" />
                <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
                <link rel="stylesheet" href="/css/mobiscroll-2.4.custom.min.css" /> 
                <script type="text/javascript" src="/js/jq.js"></script>   
                <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
                <script src="/js/mobiscroll/mobiscroll-2.4.custom.min.js"></script>
                <script type="text/javascript" src="/js/general.js"></script>
                <script type="text/javascript" src="/js/mobile_listing.js"></script>
            </xsl:when>
            <xsl:otherwise>
                <link href="/css/main.css" rel="stylesheet" type="text/css" />
                <script type="text/javascript" src="/js/jq.js"></script>
		<script type="text/javascript" src="/js/general.js"></script>
                <script type="text/javascript" src="/js/listing.js"></script>
                <script src="/js/jquery-ui/jquery-ui.custom.min.js"></script>

                <link rel="stylesheet" type="text/css" href="/js/upload/jquery.fileupload-ui.css" />
                <link href="/js/jquery-ui/css/smoothness/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" />

                <script type="text/javascript" src="/js/highslide/highslide.js"></script>
                <link rel="stylesheet" type="text/css" href="/js/highslide/highslide.css" />
                <script type="text/javascript" src="/js/highslide/config.js"></script>

                <script src="/js/jcrop/jquery.Jcrop.min.js"></script>
                <link rel="stylesheet" href="/js/jcrop/jquery.Jcrop.css" type="text/css" />
                <script src="/js/jcrop/config.js"></script>

                <script src="/js/popup/popup.js">/**/</script>
                <link rel="stylesheet" href="/js/popup/popup.css" type="text/css" />
            </xsl:otherwise>
        </xsl:choose>
      </head>
      <body class="claro">
        <!--<input id="koatuu_region" type="hidden" value="{$User/koatuu_region}"/>-->
        <div class="layout" data-role="page" id="index">
          <div class="header" data-theme="a" data-role="header">

            <div class="user-info">
              <a href="{$Settings/main_url}">
                <xsl:value-of select="$Settings/website_name" />
              </a>  | <a href="javascript:;" class="gotosite" onclick="clean_cache();">почистить Cache</a>  |  <b>
                <a href="/accounts/{$User/id}">
                  <xsl:value-of select="$User/name"/>
                </a>
              </b> |  <a href="/auth/logout">Выход</a>

            </div>
            <div class="mainmenu">
              <ul>
                <xsl:for-each select="$Cats/row[level=3]">
                  <xsl:if test="is_show = 1">
                    <li onmouseover="$(this).find('div.submenu').show(); $(this).addClass('hover');" onmouseout="$(this).find('div.submenu').hide(); $(this).removeClass('hover');">
                      <xsl:if test="id != 89">
                        <xsl:attribute name="class">dropdown</xsl:attribute>
                      </xsl:if>
                      <xsl:choose>
                        <xsl:when test="url != ''">
                          <a href="{url}">
                            <xsl:if test="@active">
                              <xsl:attribute name="class">on</xsl:attribute>
                            </xsl:if>
                            <xsl:value-of select="title"/>
                          </a>
                        </xsl:when>
                        <xsl:otherwise>
                          <span>
                            <xsl:if test="@active">
                              <xsl:attribute name="class">on</xsl:attribute>
                            </xsl:if>
                            <xsl:value-of select="title"/>
                          </span>
                        </xsl:otherwise>
                      </xsl:choose>

                      <xsl:if test="$Cats/row[parent_id = current()/id and is_show = 1]">
                        <div class="submenu" style="display:none;">
                          <ul>
                            <xsl:for-each select="$Cats/row[parent_id = current()/id and is_show = 1]">
                              <li>
                                <a href="{url}">
                                  <xsl:if test="@active">
                                    <xsl:attribute name="class">on</xsl:attribute>
                                  </xsl:if>
                                  <xsl:value-of select="title"/>
                                </a>
                              </li>
                            </xsl:for-each>
                          </ul>

                        </div>
                      </xsl:if>

                    </li>
                  </xsl:if>
                </xsl:for-each>
              </ul>
              <br class="spacer"/>
            </div>
          </div>





          <div class="content" data-role="content">



            <xsl:apply-templates select="content" />

            <br class="spacer"/>


          </div>


        </div>

        <footer>

          © 2013 <xsl:value-of select="$Settings/title"/><xsl:text> </xsl:text><xsl:value-of select="$Settings/version"/>

        </footer>
        
        <xsl:if test="$Settings/is_mobile = ''">
            
                <div class="highslide-html-content" id="highslide-html">
                  <div class="highslide-header">
                    <ul>
                      <li class="highslide-move">

                      </li>

                    </ul>
                  </div>
                  <div class="highslide-body" style="height: 220px">
                    <span id="spanButtonPlaceholder"></span>
                    <div id="divFileProgressContainer"></div>
                    <div id="thumbnails">
                      <img/>
                      <xsl:for-each select="$Main/photos/row">
                        <img style="margin: 5px; opacity: 1; cursor: hand;" src="{$Files}{path}{id}square_small{file_name}" onclick="insert_tiny_img('{$Files}{path}{id}blog{file_name}')"/>
                      </xsl:for-each>
                    </div>
                  </div>
                  <div class="go">


                    <input type="button"  class="submit" value="Відміна" onclick="return hs.close(this)"/>
                  </div>

                </div>


                <!-- Load new avatar -->
                <div class="highslide-html-content " id="avatar_edit">
                  <div class="highslide-header">
                    <ul>
                      <li class="highslide-move">
                      </li>
                    </ul>
                  </div>
                  <div class="highslide-body popup-message">
                    <form id="form1" action="" enctype="multipart/form-data" method="post">

                      <div class="small-text">
                        <input type="hidden" id="upload_avatar_url" value="/{$Controller}/upload-avatar/id/{$Main/@id}"/>
                        <input type="text" id="txtFileName" disabled="true"   />
                        <span id="spanButtonPlaceholderAvatar"></span>
                        (10 MB max)
                      </div>
                      <div class="flash" id="fsUploadProgressAvatar">
                        <!-- This is where the file progress gets shown.  SWFUpload doesn't update the UI directly.
                                                                                                The Handlers (in handlers.js) process the upload events and make the UI updates -->
                      </div>


                      <div class="small-text">
                        <p>Можна завантажити файл формату JPG, GIF або PNG. (Не завантажуйте картинки, що містять зображення публічних людей, оголеної натури, творів мистецтва, а також зображення, захищені авторськими правами.)</p>
                      </div>

                      <div class="go">

                        <input type="button"  class="submit" value="Загрузити" onclick="" id="btnSubmit"/>
                        <input type="button"  class="submit" value="Скасувати" onclick="return hs.close(this)"/>
                      </div>
                    </form>
                  </div>
                </div>

                <!-- General Message Box -->
                <div id="popup_msg">
                </div>

                <!-- Crop Loaded avatar -->
                <!--
                <div class="highslide-html-content " id="avatar_crop">
                  <div class="highslide-header">
                    <ul>
                      <li class="highslide-move">
                      </li>
                    </ul>
                  </div>
                  <div class="highslide-body popup-message">
                    <input value="0" type="hidden" rel="x"/>
                    <input value="0" type="hidden" rel="y"/>
                    <input value="0" type="hidden" rel="w"/>
                    <input value="0" type="hidden" rel="h"/>

                    <table>
                      <tr>
                        <td>
                          <img src="{$Files}{$Form/path}{$Form/id}original{$Form/file_name}" class="cropbox" />
                        </td>
                        <td>
                          <div style="width:162px;height:125px;overflow:hidden;" class="preview">
                            <img src="{$Files}{$Form/path}{$Form/id}original{$Form/file_name}" class="preview"/>
                          </div>
                        </td>
                      </tr>
                    </table>
                    <div class="go">
                      <input type="button" class="submit" value="Вирізати" onclick="cropSelected({$Main/@id}, '{$Controller}')"/>
                      <input type="button" class="submit" value="Скасувати" onclick="window.location.reload( true );"/>
                    </div>

                              </div>
                            </div>
                            -->


                            <!-- Load photos -->
                            <div class="newpopup" id="load_xml" style="display:none;">
                                <div class="wrap">
                                    <div class="header">
                                        <h3>Завантажити фотографії</h3>
                                    </div>
                                    <div class="body">
                                        <form id="form1" action="" enctype="multipart/form-data" method="post">
                                            <div id="fileupload_xml">
                                                <input type="file" name="files" multiple=""/>
                                                <input type="hidden" name="controller" value="{$Controller}"/>
                                                <input type="hidden" name="id" value="{$Main/@id_this}"/>
                                                <div class="progressbar" style="display:none;">
                                                    <div class="info">0%</div>
                                                    <div style="width:0%;" class="bar"></div>
                                                </div>
                                                <div class="fileupload-progress"></div>
                                            </div>

                                            <div class="small-text">
                                                <p>Можна завантажити файл формату JPG, GIF або PNG. (Не завантажуйте картинки, що містять зображення публічних людей, оголеної натури, творів мистецтва, а також зображення, захищені авторськими правами.)</p>
                                            </div>

                                        </form>
                                    </div>
                                    <div class="footer">
                                        <input type="button" value="Закрити" onclick="popup.close();"/>
                                    </div>
                                </div>
                            </div>

                            <div class="newbg" style="display:none;" id="disable-layout"> </div>
                </xsl:if>
            </body>
        </html>
    </xsl:template>

    <xsl:template name="Logo">
        <div class="logo">
            <a href="/">
                <img src="/images/logo.png"/>
            </a>
        </div>
    </xsl:template>


    <xsl:template name="Create_Path">
        <xsl:param name="last"></xsl:param>
        <xsl:param name="last_url"></xsl:param>
        <xsl:param name="without_last"></xsl:param>

        <div class="path">
            <xsl:for-each select="$Content/Path/row">
                <xsl:if test="not($without_last = 1 and position() = last())">
                    <xsl:choose>
                        <xsl:when test="url != ''">
                            <a href="{url}">
                                <xsl:value-of select="name"/>
                            </a> &gt;
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="name"/> &gt;
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:if>
            </xsl:for-each>

            <xsl:choose>
                <xsl:when test="$last_url = ''">
                    <xsl:value-of select="$last"/>
                </xsl:when>
                <xsl:otherwise>
                    <a href="{$last_url}">
                        <xsl:value-of select="$last"/>
                    </a>
                </xsl:otherwise>
            </xsl:choose>
        </div>
    </xsl:template>

    <xsl:template name="Messages">
        <xsl:if test="Main/form/@sent = 1">
            <div>
                <xsl:if test="Main/form/@error = 1">
                    <xsl:attribute name="class">massage_no</xsl:attribute>
                </xsl:if>
                <xsl:if test="Main/form/@error = 0">
                    <xsl:attribute name="class">massage_yes</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="Main/form/@message" />
            </div>
        </xsl:if>

    </xsl:template>

    <xsl:template name="Box-File">

        <xsl:if test="$Form/file_name_var != ''">


            <div class="head-slide on">
                Файл
            </div>
            <div class="container">
                <ul class="editlist">
                    <li>
                        <label>Путь до файлу</label>
                        <a href="{$Files}{$Form/path}{$Form/file_name_var}">Завантажити</a>
                    </li>
                    <li>
                        <label>Розмір</label>
                        <xsl:value-of select="$Form/file_size"/>
                    </li>
                </ul>
            </div>

        </xsl:if>
    </xsl:template>

    <xsl:template name="Box-CEO">
        <div class="head-slide off">
            META Тэги
        </div>

        <div id="ceo_tags" class="container" style="display:none;">
            <fieldset>
                <ul class="editlist">
                    <li>
                        <label>Title</label>

                        <textarea name="ceo_title" class="broad100">
                            <xsl:value-of select="Main/form/ceo_title"/>
                        </textarea>

                    </li>

                    <li>
                        <label>META Description</label>

                        <textarea name="ceo_desc" class="broad100">
                            <xsl:value-of select="Main/form/ceo_desc"/>
                        </textarea>

                    </li>

                    <li>
                        <label>META Keywords (через кому</label>

                        <textarea name="ceo_keywords" class="broad100">
                            <xsl:value-of select="Main/form/ceo_keywords"/>
                        </textarea>
                    </li>
                </ul>
            </fieldset>
        </div>
    </xsl:template>

    <xsl:template name="Box-Avatar">
        <div class="head-slide on">
            Аватар
        </div>

        <div class="container">
            <div>
                <xsl:if test="$Form/file_name != ''">
                    <xsl:attribute name="style">display:none</xsl:attribute>
                </xsl:if>
                <a href="javascript:;" onclick="editAvatar()" id="load_avatar" class="upload">Завантажити зображення  </a>
            </div>
            <div class="avacontainer" onmouseover="$(this).find('div.tools').show()" onmouseout="$(this).find('div.tools').hide()">


                <div class="tools" style="display:none">
                    <a href="javascript:;" class="editava" onclick="editAvatar()" title="Редактирывать"></a>
                    <a href="javascript:;" class="cropava" onclick="cropAvatar($('#avatar').width(),$('#avatar').height())" title="Вирізати"></a>
                    <a href="javascript:;" class="removeava" onclick="removeAvatar({$Main/@id}, '{$Controller}')" title="Видалити"></a>
                    <a href="{$Files}{$Form/path}{$Form/id}original{$Form/file_name}" title="Оригинал" target="_blank"  class="fullsize"></a>
                </div>


                <img src="{$Files}{$Form/path}{$Form/id}avatar{$Form/file_name}" width="200px" id="avatar" alt="{$Form/title}" title="{$Form/title}">
                    <xsl:if test="$Form/file_name = ''">
                        <xsl:attribute name="style">display:none</xsl:attribute>
                    </xsl:if>
                </img>

            </div>
        </div>
    </xsl:template>

    <xsl:template name="Lang">
        <div class="lang">
            <span>Язык:</span>
            <span id="tab_1" onclick='javascript: change_tab(1);' class='tab on'>Російська</span>
            <span id="tab_2" onclick='javascript: change_tab(2);' class='tab'>Українска</span>
            <span id="tab_3" onclick='javascript: change_tab(3);' class='tab'>Англійска</span>
        </div>
    </xsl:template>

    <xsl:template name="Article-edit-switcher">
        <xsl:param name="active"/>
        <xsl:param name="arts"/>
        <div class="innerNav">
            <ul>
                <li>
                    <a href="/{$Controller}/{$Main/@id}">
                        <xsl:if test="$active = 1">
                            <xsl:attribute name="class">on</xsl:attribute>
                        </xsl:if>
                        Основна інформація
                    </a>
                </li>
                <li>
                    <a href="/{$Controller}/photos/{$Main/@id}">
                        <xsl:if test="$active = 2">
                            <xsl:attribute name="class">on</xsl:attribute>
                        </xsl:if>
                        Фотографії
                    </a>
                </li>
                <xsl:if test="$arts = 1">
                    <li>
                        <a href="/{$Controller}/arts/{$Main/@id}">
                            <xsl:if test="$active = 3">
                                <xsl:attribute name="class">on</xsl:attribute>
                            </xsl:if>
                            Параметри
                        </a>
                    </li>
                    <li>
                        <a href="/{$Controller}/childs/{$Main/@id}">
                            <xsl:if test="$active = 4">
                                <xsl:attribute name="class">on</xsl:attribute>
                            </xsl:if>
                            Прикріплені продукти
                        </a>
                    </li>
                </xsl:if>
            </ul>
            <br class="spacer"/>
        </div>

    </xsl:template>

    <!-- Write.Date -->
    <xsl:template name="Write.Date">
        <xsl:param name="node"></xsl:param>

        <xsl:choose>
            <xsl:when test="$node/@day = $Date/@day and $node/@dmonth = $Date/@dmonth and $node/@year = $Date/@year">
                Сьогодні
            </xsl:when>
            <xsl:when test="$node/@day = $Date/@day+1 and $node/@dmonth = $Date/@dmonth and $node/@year = $Date/@year">
                Вчора
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$node/@day"/>
                <xsl:text>.</xsl:text>
                <xsl:value-of select="$node/@dmonth"/>
                <xsl:text>.</xsl:text>
                <xsl:value-of select="$node/@year"/>
            </xsl:otherwise>
        </xsl:choose>

    </xsl:template>

    <!-- Write.Date.Time -->
    <xsl:template name="Write.Date.Time">
        <xsl:param name="node"></xsl:param>
        <xsl:call-template name="Write.Date">
            <xsl:with-param name="node" select="$node"/>
        </xsl:call-template>
        <xsl:text> </xsl:text>
        <xsl:value-of select="$node/@hour"/>
        <xsl:text>:</xsl:text>
        <xsl:value-of select="$node/@minute"/>
    </xsl:template>

</xsl:stylesheet>
